package com.twu.biblioteca;

import java.io.*;

public class BibliotecaApp {

    public static void main(String[] args) {
        Message welcome = new Message("Welcome");
        Menu menu = new Menu();
        System.out.println(welcome.getWelcomeMessage());
        System.out.println(menu.getMenuOptions());

        String line;
        InputStreamReader converter = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(converter);
        try {

            line = reader.readLine();
            while (!(line.equals("exit"))) {

                String output = menu.selectOption(line);
                System.out.println(output);

                if(line.equals("2")) {
                    System.out.println("Enter Book Title: ");
                    String title = reader.readLine();
                    System.out.println(menu.reserveBook(title));

                }

                if(line.equals("4"))
                {
                    System.out.println("Enter username");
                    String username = reader.readLine();
                    username = username.replace("-", "");
                    System.out.println("Enter password");
                    String password = reader.readLine();


                    menu.login(Integer.parseInt(username), password);
                }

                System.out.println("\n" + menu.getMenuOptions());
                line = reader.readLine();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }



    }


}
